from psycopg_pool import AsyncConnectionPool


def init_postgres_pool():
    DB_URI = "postgresql://postgres:123456@117.72.198.65:5432/oa_agent?sslmode=disable"
    connection_kwargs = {
        "autocommit": True,
        "prepare_threshold": 0,
    }

    # 创建连接池但不使用with语句
    pool = AsyncConnectionPool(
        conninfo=DB_URI,
        max_size=20,
        kwargs=connection_kwargs,
    )

    return pool
